home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1997 November & December / Amiga-CD 1997 #11-12.iso / pd-disketten / dms-gepackt / 8_95 / apd-8-95-2.dms / apd-8-95-2.adf / Psion / Developer / Source / ncplib / openncp.c < prev    next >
C/C++ Source or Header  |  1986-10-26  |  1KB  |  64 lines

  1. /*
  2. **    SAS/C 6.51 constructor for opening
  3. **  "ncp.library"
  4. **
  5. **  $VER: ncp.lib 1.1
  6. **/
  7.  
  8. #include <constructor.h>
  9. #define __USE_SYSBASE
  10. #include <proto/exec.h> 
  11. #include <exec/execbase.h>
  12. #include <proto/intuition.h>
  13. #include <proto/dos.h>
  14. #include <libraries/ncplib.h>
  15. #include <string.h>
  16. struct Library *NCPBase;
  17. static struct Library *libbase;
  18.  
  19. CONSTRUCTOR_P(ncplib,500)
  20. {
  21.     struct EasyStruct eas;
  22.     char buffer[ 128 ];
  23.     struct Task *pr = FindTask( NULL );
  24.  
  25.     if( SysBase->LibNode.lib_Version < 37 )
  26.         return( 1 );
  27.  
  28.     FOREVER
  29.     {
  30.         libbase = OpenLibrary( NCP_NAME, NCP_VERSION );
  31.         if( !libbase )
  32.             libbase = OpenLibrary( "PROGDIR:" NCP_NAME, NCP_VERSION );
  33.         if( !libbase )
  34.             libbase = OpenLibrary( "PROGDIR:Libs/" NCP_NAME, NCP_VERSION );
  35.         if( libbase )
  36.         {
  37.             NCPBase = libbase;
  38.             return( 0 );
  39.         }
  40.  
  41.         eas.es_StructSize = sizeof( eas );
  42.         eas.es_Flags = 0;
  43.         eas.es_Title = buffer;
  44.         strncpy( buffer, pr->tc_Node.ln_Name, 127 );
  45.         if( Cli() )
  46.             GetProgramName( buffer, 127 );
  47.         buffer[ 127 ] = 0;
  48.         eas.es_TextFormat = "Requires V%ld (or higher))\nof \"" NCP_NAME "\"";
  49.         eas.es_GadgetFormat = "Retry|Cancel";
  50.         if( !EasyRequest( NULL, &eas, NULL, NCP_VERSION ) )
  51.             return( 1 );
  52.  
  53.    }
  54. }
  55.  
  56. DESTRUCTOR_P(ncplib,500)
  57. {
  58.    if (libbase)
  59.    {
  60.       CloseLibrary((struct Library *)libbase);
  61.       libbase = NCPBase = NULL;
  62.    }
  63. }
  64.